#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stdio.h>

using namespace std;

/**
 *  2023.11.8：测试翻转字符串
 */
void testReverseString() {
    string studentNo = "20231108";
    reverse(studentNo.begin(), studentNo.end());
    cout << "studentNo is: " << studentNo << endl;
}

/**
 * 2023.11.8：将单词转换为大写
 */
void testUpperCase() {
    string teacherName = "eric";
    transform(teacherName.begin(), teacherName.end(), teacherName.begin(), ::toupper);
    cout << "Teacher Name is: " << teacherName << endl;
}

/**
 * 2023.11.8：将单词转换为小写
 */
void testLowerCase() {
    string teacherName = "Frank";
    transform(teacherName.begin(), teacherName.end(), teacherName.begin(), ::tolower);
    cout << "Teacher Name is: " << teacherName << endl;
}

void hanldeString(string *teacherName) {
    transform((*teacherName).begin(), (*teacherName).end(), (*teacherName).begin(), ::tolower);
}

void hanldeString2(string studName) {
    transform((studName).begin(), (studName).end(), (studName).begin(), ::tolower);
    //2023.11.8, 在函数里头是生效的
    cout << "The converted studName(in method) is:" << studName << endl;
}

/**
 * 获取当前时间
 */
void getCurrentTime() {
    time_t currentTime;
    //首先创建一个time_t 类型的变量nowtime
    struct tm *p;
    //然后创建一个新时间结构体指针 p
    time(&currentTime);
    //使用该函数就可得到当前系统时间，使用该函数需要将传入time_t类型变量nowtime的地址值。
    p = localtime(&currentTime);
    //由于此时变量nowtime中的系统时间值为日历时间，我们需要调用本地时间函数p=localtime（time_t* currentTime）将nowtime变量中的日历时间转化为本地时间，存入到指针为p的时间结构体中。不改的话，可以参照注意事项手动改。
    printf("%02d:%02d:%02d\n", p->tm_hour, p->tm_min, p->tm_sec);
}

int main() {
    std::cout << "Hello, World!" << std::endl;
    cout << "我是中国人" << endl;
    testReverseString();
    testUpperCase();
    testLowerCase();
    string teacherName = "FAN YU SONG";
    cout << "teacherName is:" << teacherName << endl;
    hanldeString(&teacherName);
    cout << "The converted teacherName is:" << teacherName << endl;
    string studName = "KITTY";
    cout << "studName is:" << studName << endl;
    //由于没有传入指针，所以调用函数其实是不生效的
    hanldeString2(studName);
    cout << "The converted studName is:" << studName << endl;
    getCurrentTime();

    return 0;
}
